package com.westcom.healthmate.common.network.http;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import com.westcom.healthmate.common.utils.CommonUtils;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;

public class Response
{
    private int httpCode;
    private String errorMsg;
    private HttpResponse mOriginalData = null;
    private String body = null;

    public Response(int httpCode, String errmsg)
    {
        this.httpCode = httpCode;
        this.errorMsg = errorMsg;
    }
    public Response(HttpResponse res)
    {
    	this(res.getStatusLine().getStatusCode(),res.getStatusLine().getReasonPhrase());
        this.mOriginalData = res;
        body = CommonUtils.getEntityAsString(this.mOriginalData);
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    public HttpResponse getmOriginalData() {
        return mOriginalData;
    }

    public void setmOriginalData(HttpResponse mOriginalData) {
        this.mOriginalData = mOriginalData;
    }

    public int getHttpCode() {
        return httpCode;
    }

    public void setHttpCode(int httpCode) {
        this.httpCode = httpCode;
    }

    public String getBody() {
        return body;
    }

    public void setBody(String body) {
        this.body = body;
    }
    public boolean isSuccessed()
    {
        if(this.httpCode == HttpStatus.SC_OK || this.httpCode == HttpStatus.SC_CREATED)
        {
            return true;
        }
        return false;
    }
}